package com.project.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.project.bean.LessonBean;
import com.project.service.ILessonService;

@Controller
public class LessonController {
	@Autowired
	private ILessonService lessonService;
	
	@RequestMapping("/show_lesson_other")
	public String showOther(Model model,int lUId) {
		List<LessonBean> lessons = lessonService.showLessons(lUId);
		model.addAttribute("lessons", lessons);
		return "coach_lesson_other.html";	
	}
	
	@RequestMapping("/show_lesson_self")
	public String showSelf(Model model,HttpSession session) {
		int lUId=(int) session.getAttribute("UId");
		List<LessonBean> lessons = lessonService.showLessons(lUId);
		model.addAttribute("lessons", lessons);
		return "coach_lesson_self.html";	
	}
	
	@RequestMapping("/changeLesson")
	@ResponseBody
	public int changeLesson(int lId,double lPrice,int lState) {
		int num = 0;
		num = lessonService.updateLesson(lId, lPrice, lState);
		return num;
	}
}
